#include <bits/stdc++.h>
#define int long long
using namespace std;
int f[1005], g[1005];
const long long MOD = 998244353;
signed main()
{
	freopen("drama.in","r",stdin);
	freopen("drama.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    f[n] = 1;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            g[j] = 0;
            for (int k = 1; k <= n; k++)
            {
                if (j == n)
                {
                    if (k == n) g[j] += f[n];
                    if (k == n-1) g[j] += f[k];
                }
                else if (j == 1)
                {
                    if (k == 1) g[j] += (n-1) * f[1] % MOD;
                    else g[j] += f[k];
                }
                else 
                {
                    if (k == j) g[j] += (n-j) * f[k] % MOD;
                    else if (k == j-1 || k > j) g[j] += f[k] % MOD;
                }
                g[j] %= MOD;
            }
        }
        for (int j = 1; j <= n; j++) f[j] = g[j];
       // for (int j = 1; j <= n; j++) cout << f[j] << ' ';
        //cout << endl;
    }
    cout << f[n];
    return 0;
}
